package com.realgodo.site.entity.space;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.realgodo.site.entity.IdEntity;

@Entity
@Table(name = "meimei_message")
public class Message extends IdEntity {

	private static final long serialVersionUID = 45553816271266835L;

	private String title;

	private String content;

	private Space sender;

	private Space receiver;

	private Message subject;

	public static int READ = 1;
	public static int NOT_READ = 0;
	private int status;

	private Date createDate = new Date();

	@Column(name = "title", length = 100)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content", length = 500)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@ManyToOne
	@JoinColumn(name = "sender_id", referencedColumnName = "id", nullable = true)
	public Space getSender() {
		return sender;
	}

	public void setSender(Space sender) {
		this.sender = sender;
	}

	@ManyToOne
	@JoinColumn(name = "receiver_id", referencedColumnName = "id", nullable = false)
	public Space getReceiver() {
		return receiver;
	}

	public void setReceiver(Space receiver) {
		this.receiver = receiver;
	}

	@ManyToOne
	@JoinColumn(name = "subject_id", referencedColumnName = "id", nullable = true)
	public Message getSubject() {
		return subject;
	}

	public void setSubject(Message subject) {
		this.subject = subject;
	}

	@Column(name = "status")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_date")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

}
